package com.ydcycloud.log.controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smart.mvc.model.Pagination;
import com.smart.mvc.model.Result;
import com.smart.mvc.validator.Validator;
import com.smart.mvc.validator.annotation.ValidateParam;
import com.ydcycloud.log.service.SysLogService;
import com.ydcycloud.sys.controller.BaseAdminController;

@Controller
@RequestMapping("/admin/sysLog")
public class SysLogController  extends BaseAdminController{
	@Resource
	private SysLogService sysLogService;
	
	
	@RequestMapping(value = "index", method = RequestMethod.GET)
	public String execute(Model model) {

		return "admin/system/sysLog";
	}

	@RequestMapping(path = "/list", method = { RequestMethod.GET,
			RequestMethod.POST })
	@ResponseBody
	public Result list(
			@ValidateParam(name = "开始页码", validators = { Validator.NOT_BLANK }) Integer pageNo,
			@ValidateParam(name = "显示条数 ", validators = { Validator.NOT_BLANK }) Integer pageSize) {

		Pagination<Map<String, Object>> p = sysLogService.findPagination(
				pageNo, pageSize);
		return Result.createSuccessResult().setData(p);
	}


	@RequestMapping(path = "/del", method = { RequestMethod.GET,
			RequestMethod.POST })
	@ResponseBody
	public Result del() {
		try {
			sysLogService.logDel();
			return Result.createSuccessResult().setMessage("已处理完毕");

		} catch (Exception e) {
			e.printStackTrace();
			return Result.createErrorResult().setMessage("系統错误");
		}
	}
	
	
}
